package base.optional;

import java.util.Optional;

/**
 *
 * @author scylla
 * @version V1.0
 * @project echo-java-base
 * @title
 * @package base.stream
 * @since 2022/6/7 5:06 下午
 */
public class DemoImpl implements DemoInterface{

    public void test(){
        test1();
    }

    @Override
    public String test1() {
        return "c-test1";
    }

    @Override
    public String test2() {
        return "c-test2";
    }

    public static DemoImpl getInstance(boolean isnull){
        return isnull ? null : new DemoImpl();
    }

    public static void main(String[] args) {
        DemoImpl demo = DemoImpl.getInstance(true);

        Optional.ofNullable(demo).ifPresent(d->{
            System.out.println(demo.test1());
            System.out.println(demo.test2());
        });




    }

}
